;(function($){
        window.Cookie = {
                setCookie : function(name,val,expires){


                        //元素存在与否     元素存在   去除左右空格之后   长度是否为零
                        val+="";
                        if(!name || !val || name.trim().length == 0 || val.trim().length == 0){

                                return;
                        }
                        if (expires) {
                                expires = this._getTime(expires);
                                // console.log(expires);
                                document.cookie = name + "=" + val + ";expires=" + expires;
                                return;
                        }
                        document.cookie = name + "=" + encodeURIComponent(val);
                },
                removeCookie : function(name){

                        var cookies = document.cookie;
                        // 判断cookie是否存在
                        if (cookies.indexOf(";") != -1) {
                                array = cookies.split(";");
                        }else {
                                array = [cookies];
                        }
                        for (var i = 0; i < array.length; i++) {
                                var str = array[i];
                                str = str.split("=");
                                // 判断是否存在   键名为:name的数值
                                if (str[0] == name) {
                                        this.setCookie(name,".","s-1");
                                }
                        }
                },
                // 非官方规定  私有方法  虽然在外部仍可以使用
                // 但程序员之间规定其为私有方法  之间默认的方法
                _getTime : function(expires){
                        var first = expires.substring(0,1);
                        var second = expires.split(first)[1];
                        var time = new Date().getTime();
                        if (first == "s") {
                                time += second * 1000;
                        }else if (first == "m") {
                                time += second * 1000 * 60;
                        }else if (first == "h") {
                                time += second * 1000 * 60 * 60;
                        }else if (first == "d"){
                                time += second * 1000 * 60 * 60 * 24;
                        }else if (first == " M") {
                                time += second * 1000 * 60 * 60 * 24 * 30;
                        }else if (first == "y") {
                                time += second * 1000 * 60 * 60 * 24 * 30 * 365;
                        }
                        return new Date(time).toUTCString();
                },
                getCookie : function(name){

                        var cookies = document.cookie;
                        var array = null;
                        var cObj = {};
                        if (cookies.length > 0) {
                                // 判断cookie是否存在
                                if (cookies.indexOf(";") != -1) {
                                        array = cookies.split(";");
                                }else {
                                        array = [cookies];
                                }
                                for (var i = 0; i < array.length; i++) {
                                        var str = array[i];
                                        str = str.split("=");
                                        cObj[str[0].trim()] = str[1];
                                }
                                if (cObj[name]) {
                                        return decodeURIComponent(cObj[name]);
                                }else {
                                        return cObj;
                                }
                        }
                }
        }
})(jQuery);
